import { _decorator, Component, Animation, SpriteFrame } from 'cc';
import { DIRECTION_ORDER_ENUM, FSM_PARAMS_TYPE_ENUM, PARAMS_NAME_ENUM } from '../scripts/enums';
import State from './State';
import { StateMachine } from './stateMachine';


export abstract class SubStateMachine {
    private _currentState: State = null;

    _stateMachines: Map<string, State> = new Map();

    constructor(public _fsm: StateMachine) {}

    get currentState() { return this._currentState; }

    set currentState(newState: State) {
        this._currentState = newState;
        this._currentState.run();
    }

    run(): void {
        const value = this._fsm.getParams(PARAMS_NAME_ENUM.DIRECTION);
        this.currentState = this._stateMachines.get(DIRECTION_ORDER_ENUM[value as number]);
    }
}
